<form action="<?=PATH_URL.'contest/contest_register'?>" method="POST" name="contest_register" id="contest_register">
<div>
IMAGE
<input type="file" name="fileFrontend"/><br />
<span id="image-error" class="red"></span>
</div>
<div>
FULLNAME
<input type="text" name="fullname"/><br />
<span id="fullname-error" class="red"></span>
</div>
<div>
EMAIL
<input type="text" name="email"/><br />
<span id="email-error" class="red"></span>
</div>
<div>
ADDRESS
<input type="text" name="address"/><br />
<span id="address-error" class="red"></span>
</div>
<div>
PHONE
<input type="text" name="phone"/><br />
<span id="phone-error" class="red"></span>
</div>
<input type="button" name="clickSubmit" id="clickSubmit" value="Hoan tat"/>
<span id="success-error" class="red"></span>
</form>
<script type="text/javascript">
    function clearError()
    {
        $("#fullname-error").html('');
        $("#email-error").html('');
        $("#address-error").html('');
        $("#phone-error").html('');
        $("#register-success").html('');
        $("#image-error").html('');
        $("#success-error").html('');
    }
	
	$(document).ready(function(){
		$("#clickSubmit").click(function(){
			clearError();
			var post_data = {
                'fullname' : $("input[name=fullname]").val(),
                'email' : $("input[name=email]").val(),
                'address' : $("input[name=address]").val(),
                'phone' : $("input[name=phone]").val(),
                'image' : $("input[name=fileFrontend]").val()
            };
			
			$.ajax({
                 url: '<?=PATH_URL.'contest/contest_register'?>',
                 data: post_data,
                 type: 'POST',
                 dataType: 'json',
                 success: function(data) {
					if(data.status == "1")
					{
						$("#contest_register").get(0).reset();
						$("#"+data.code).html(data.message);
						return false;
					}else{
						$("#"+data.code).html(data.message);
						return false;
					}
                 }
            });
			return false;
		});
	});
</script>
